<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<table cellpadding="5" style="margin-left: 30px" id="itemParamAddTable" class="itemParam">
	<tr class="hide addGroupTr">
		<td>属性参数:</td>
		<td>
			<ul>
				<li><a href="javascript:void(0)" class="easyui-linkbutton addProperty">添加属性</a></li>
			</ul>
		</td>
	</tr>
	<tr>
		<td></td>
		<td>
			<a href="javascript:void(0)" class="easyui-linkbutton submit">提交</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton close">关闭</a>
		</td>
	</tr>
  </table>
  
  <div  class="itemParamAddTemplate" style="display: none;">
	<li class="param">
		<ul>
			<li>
				<input  style="width: 150px;" class="easyui-textbox" name="param"/>&nbsp;<a href="javascript:void(0)" class="easyui-linkbutton delParam" title="删除" data-options="plain:true,iconCls:'icon-cancel'"></a>						
			</li>
		</ul>
	</li>
</div>
<script style="text/javascript">
$(function(){
		var nodeId=$("#idValue").val(); //从父页面隐藏域获取的编辑的分类Id
		$(".addProperty").click(function(){
			  var temple = $(".itemParamAddTemplate li").eq(1).clone();
			  $(this).parent().parent().append(temple);
			  temple.find(".delParam").click(function(){
				  $(this).parent().remove();
			  });
		});
		$("#itemParamAddTable .close").click(function(){
			$(".panel-tool-close").click();
		});
		$("#itemParamAddTable .submit").click(function(){
			var params = [];
			var groups = $("#itemParamAddTable [name=param]");
			groups.each(function(i,e){
				var _val = $(e).siblings("input").val();
				if($.trim(_val).length>0){
					params.push(_val);	
				}
			});
			var url = "property/savePropertyParam/"+nodeId;
			$.post(url,{"paramData":JSON.stringify(params)},function(data){
				try{
					if(data.status == 200){
						$.messager.alert('提示','新增商品属性成功!',undefined,function(){
							$(".panel-tool-close").click();
	    					$("#propertyData").datagrid("reload");
	    				});
					}else if(data.status==403){
						$.messager.alert('提示','提交参数错误!','info');
					}
				}catch (e) {
					$.messager.alert('提示','操作失败!','info');
					$(".panel-tool-close").click();
				}
				
			}); 
		});
	}); 
</script>